package meihua.stopcarapp.model;

import meihua.mylibrary.basebean.ResultModel;
import meihua.mylibrary.baserx.RxSchedulers;
import meihua.stopcarapp.api.Api;
import meihua.stopcarapp.api.URLType;
import meihua.stopcarapp.bean.result.MyWalletResult;
import meihua.stopcarapp.presenter.contract.MyWalletContract;
import rx.Observable;
import rx.functions.Func1;

/**
 * Name: LGZ
 * Time: 2017/5/18.
 * Dec:
 */

public class MyWalletModel implements MyWalletContract.Model {
    @Override
    public Observable<MyWalletResult> getMyWallet(String user_id) {
        return Api.getDefault(URLType.STOPCAR_URL)
                .getMyWallet(user_id)
                .map(new Func1<ResultModel<MyWalletResult>, MyWalletResult>() {
                    @Override
                    public MyWalletResult call(ResultModel<MyWalletResult> userResultModel) {
                        return userResultModel.getData();
                    }
                })
                .compose(RxSchedulers.<MyWalletResult>io_main());
    }
}
